Skip to content

feat(grpc): Support span streaming#6204

Open
alexander-alderman-webb wants to merge 13 commits intomasterfrom
webb/grpc/span-first
Open

feat(grpc): Support span streaming#6204
alexander-alderman-webb wants to merge 13 commits intomasterfrom
webb/grpc/span-first

Conversation

@alexander-alderman-webb
Copy link
Copy Markdown
Contributor

@alexander-alderman-webb alexander-alderman-webb commented May 5, 2026

Description

In the streaming path, use

  • rpc.method instead of method
  • rpc.response.status_code instead of code

Dropped attributes:

  • type

Adapting Tests

sed commands used for converting transaction context managers:

  • sed -i '' 's/with start_transaction() as transaction:/with sentry_sdk.traces.start_span(name="custom parent") as span:/g'
  • sed -i '' 's/with sentry_sdk.start_transaction() as transaction:/with sentry_sdk.traces.start_span(name="custom parent") as span:/g'
  • sed -i '' 's/with start_transaction():/with sentry_sdk.traces.start_span(name="custom parent"):/g'
  • sed -i '' 's/with start_transaction(name="custom_transaction"):/with sentry_sdk.traces.start_span(name="custom parent"):/g'

sed commands used for converting specific attributes:

  • sed -i '' '/"type": /d'
  • sed -i '' 's/code/rpc.response.status_code/g'
  • sed -i '' 's/method/rpc.method/g'

sed commands used for converting event capture:

  • sed -i '' 's/(event, _) = events/(event, ) = (item.payload for item in items if item.type == "event")/g'
  • sed -i '' 's/local_transaction["spans"]/spans/g'
  • sed -i '' 's/events.read_event()/span = events.read_event()["payload"]/g'
  • sed -i '' 's/events = capture_events_forksafe()/items = capture_items_forksafe("event", "transaction", "span")/g'
  • sed -i '' 's/capture_events_forksafe,/capture_items_forksafe,/g'
  • sed -i '' 's/event["spans"]/spans/g'
  • sed -i '' 's/events = capture_events()/items = capture_items("event", "transaction", "span")/g'
  • sed -i '' 's/capture_events,/capture_items,/g'

sed commands used for converting op:

  • sed -i '' 's/["op"]/["attributes"]["sentry.op"]/g'

sed commands used for converting origin:

  • sed -i '' 's/["contexts"]["trace"]["origin"]/["attributes"]["sentry.origin"]/g'

sed commands used for converting description:

  • sed -i '' 's/description/name/g'

sed commands used for converting data to attributes:

  • sed -i '' 's/data/attributes/g'

sed commands for converting trace id:

  • sed -i '' 's/["contexts"]["trace"]["trace_id"]/["trace_id"]/g'

other test changes:

  • sed -i '' 's/, channel = grpc_server_and_channel/, channel = await grpc_server_and_channel(span_streaming)/g'
  • sed -i '' 's/events.read_event()/items = items.read_event()/g'
  • sed -i '' 's/events.write_file.close()/items.write_file.close()/g'

Issues

Closes #6027

Reminders

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 5, 2026

Codecov Results 📊

13 passed | Total: 13 | Pass Rate: 100% | Execution Time: 6.61s

All tests are passing successfully.

❌ Patch coverage is 2.04%. Project has 15099 uncovered lines.

Files with missing lines (5)
File Patch % Lines
server.py 0.00% ⚠️ 69 Missing
client.py 0.00% ⚠️ 55 Missing
client.py 0.00% ⚠️ 52 Missing
server.py 0.00% ⚠️ 43 Missing
consts.py 99.48% ⚠️ 2 Missing

Generated by Codecov Action

Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread sentry_sdk/integrations/grpc/aio/server.py
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review May 5, 2026 16:01
@alexander-alderman-webb alexander-alderman-webb requested a review from a team as a code owner May 5, 2026 16:01
Comment thread sentry_sdk/integrations/grpc/aio/client.py Outdated
Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread tests/integrations/grpc/test_grpc_aio.py Outdated
Comment thread tests/integrations/grpc/test_grpc_aio.py Outdated
@alexander-alderman-webb alexander-alderman-webb marked this pull request as draft May 6, 2026 10:35
Comment thread tests/integrations/grpc/test_grpc_aio.py
Comment thread tests/integrations/grpc/test_grpc_aio.py
@alexander-alderman-webb alexander-alderman-webb marked this pull request as ready for review May 6, 2026 14:43
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Can you please also add parent_span=None to sentry_sdk.traces.start_span calls where there were transactions previously? 🙏🏻

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9b14623. Configure here.


spans = [item["payload"] for item in items if item["type"] == "span"]

assert spans[0]["trace_id"] == spans[1]["trace_id"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trace continuity assertion tests same-process spans only

Medium Severity

The span_streaming path of test_grpc_client_and_servers_interceptors_integration asserts spans[0]["trace_id"] == spans[1]["trace_id"], but both spans[0] and spans[1] are server-side spans (the inner "test" span and the GRPC_SERVER span, ordered by finish time). This is trivially true since they originate from the same process. The original test verified that the server transaction's trace_id matched the client transaction's trace_id, confirming distributed trace propagation works. The new assertion no longer validates cross-process trace continuity — the core purpose of this test.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 9b14623. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrate grpc to span first

2 participants